<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>审核信息</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		body{
			background:#f1f1f1;
		}
		#box{
			width:330px;
			text-align:right;
			margin-top:40px;
		}
		input{
			width:200px;
			height:23px;
			text-align:left;
			border-radius:2px;
			border:1px solid #dadada;
			padding-left:10px;
		}
		button{
			width:100px;
			height:28px;
			border:none;
			border-radius:2px;
			background:#00aa98;
			outline:none;
			color:white;
		}
		.title{
			margin-top:10px;
		}
		.btnTit{
			margin-top:40px;
		}
		.cancel{
			background:#a1a4a9;
			margin-left:7px;
		}
	</style>
	<body>	
		<div id="box">
			<div class="title">
				<label>座位数</label>
				<input class="passengerTotal" type="text"/>
			</div>
			<div class="title">
				<label>票损</label>
				<input class="ticketLoss" type="text"/>
			</div>
			<div class="title">
				<label>票损率</label>
				<input class="ticketLossRate" type="text"/>
			</div>
			<div class="title">
				<label>出票率</label>
				<input class="ticketRate" type="text"/>
			</div>
			<div class="title">
				<label>结算单价</label>
				<input class="price" type="text"/>
			</div>
			<div class="title">
				<label>报价单价</label>
				<input class="viewAdultPrice" type="text"/>
			</div>
			<div class="title">
				<label>结算儿童价</label>
				<input class="childPrice" type="text"/>
			</div>
			<div class="title">
				<label>报价儿童价</label>
				<input class="viewChildPrice" type="text"/>
			</div>
			<div class="title">
				<label>结算婴儿价</label>
				<input class="infantPrice" type="text"/>
			</div>
			<div class="title">
				<label>报价婴儿价</label>
				<input class="viewInfantPrice" type="text"/>
			</div>
			<div class="title">
				<label>备注</label>
				<input class="remark" type="text"/>
			</div>
			<div class="title btnTit">
				<button class="sure">确认</button>
				<button class="cancel">取消</button>
			</div>
		</div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>	
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>	
		<script type="text/javascript" src="../js/common.js" ></script>
		<script>
			//页面初始化
			initialize()			
			function initialize(){				
				if(!getHref().idArr){
					var changeOneOrderData = window.parent.changeOneOrderData;
					draw(changeOneOrderData)					
				}
			}
			//渲染输入项
			function draw(changeOneOrderData){
				$(".passengerTotal").val(changeOneOrderData.passengerTotal);
				$(".ticketLoss").val(changeOneOrderData.ticketLoss);
				$(".ticketLossRate").val(changeOneOrderData.ticketLossRate);
				$(".ticketRate").val(changeOneOrderData.ticketRate);
				$(".price").val(changeOneOrderData.price);
				$(".viewAdultPrice").val(commomFun.toEmptyString(changeOneOrderData.viewAdultPrice));
				$(".childPrice").val(changeOneOrderData.childPrice);
				$(".viewChildPrice").val(commomFun.toEmptyString(changeOneOrderData.viewChildPrice));
				$(".infantPrice").val(changeOneOrderData.infantPrice);
				$(".viewInfantPrice").val(commomFun.toEmptyString(changeOneOrderData.viewInfantPrice));
			}
			//获取提交的数据
			function getData(){
				var postData = [];
				var json = {};
				if(getHref().idArr){
					var idArr = (getHref().idArr).split(",");
					$.each(idArr,function(index,item){
						jsonData(item,json,postData)
					})
				}else{
					var changeOneOrderData = window.parent.changeOneOrderData;
					jsonData(changeOneOrderData.id,json,postData)
				}	
				return postData;
			}
			//遍历数据
			function jsonData(id,json,postData){
				json = {
						id:id, 				             
						passengerTotal:$(".passengerTotal").val(), 
						ticketLoss:$(".ticketLoss").val(),
						ticketLossRate:$(".ticketLossRate").val(), 
						ticketRate:$(".ticketRate").val(),
						price:$(".price").val(),
						viewAdultPrice:$(".viewAdultPrice").val(),
						childPrice:$(".childPrice").val(),
						viewChildPrice:$(".viewChildPrice").val(),
						infantPrice:$(".infantPrice").val(),
						viewInfantPrice:$(".viewInfantPrice").val(),
						remark:$(".remark").val()
				}
				//校验
				inputCheckoutFun.seatCount.normal(json.passengerTotal,"座位数","为正整数!");//座位数校验				
				inputCheckoutFun.price.normal(json.ticketLoss,"票损","为数字,最多保留两位小数!");//票损校验
				inputCheckoutFun.rate.normal(json.ticketLossRate,"票损率","不大于100,最多保留两位小数!");//票损率校验
				inputCheckoutFun.rate.normal(json.ticketRate,"出票率","不大于100,最多保留两位小数!");//出票率校验
				inputCheckoutFun.price.normal(json.price,"结算单价","为数字，最多保留两位小数!");//结算单价校验
				inputCheckoutFun.price.normal(json.viewAdultPrice,"报价单价","为数字，最多保留两位小数!");//报价单价校验
				inputCheckoutFun.price.normal(json.childPrice,"结算儿童价","为数字，最多保留两位小数!");//结算儿童价校验
				inputCheckoutFun.price.normal(json.viewChildPrice,"报价儿童价","为数字，最多保留两位小数!");//报价儿童价校验
				inputCheckoutFun.price.normal(json.infantPrice,"结算婴儿价","为数字，最多保留两位小数!");//结算婴儿价校验
				inputCheckoutFun.price.normal(json.viewInfantPrice,"报价婴儿价","为数字，最多保留两位小数!");//报价婴儿价校验
				inputCheckoutFun.Empty(json.remark,"备注","不能为空!");//备注校验
				if(Number(json.ticketLossRate)>Number(json.ticketRate)){
					layer.msg("票损率不能大于出票率",{icon:2})
					throw "票损率不能大于出票率"; 
				}
				postData.push(json);
			}
			$(".sure").click(function(){
				var postData = getData();
				$.ajax({
					type:"post",
					url:"../order/update?temp="+Math.random(),
					contentType:'application/json;charset=utf-8',
					dataType:"json",
					data:JSON.stringify(postData),
					success:function(data){
						if(data.status==1001){
							layer.msg("修改成功",{icon:1},function(){
								closeWin();
							})
						}else{
							layer.alert("修改失败"+data.message)
						}
					}
				})
			})
			$(".cancel").click(function(){
				closeWin();
			})
		</script>
	</body>
</html>
